package de.tmahr.android;

import java.util.Locale;

import de.tmahr.android.logger.LogActivity;

import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class SpeechTest extends LogActivity 
implements OnTouchListener, OnInitListener
{
	private TextToSpeech tts; 

	public SpeechTest()
	{
		super(SpeechTest.class.getSimpleName());
	}

	@Override
	public void onCreate(Bundle b)
	{
		super.onCreate(b);
		textView.setOnTouchListener(this);
		tts = new TextToSpeech(this,this);
	}
	
	@Override
	protected void onPause()
	{
		super.onPause();
	}	

	@Override
	public boolean onTouch(View v, MotionEvent event)
	{
		if (event.getAction() == MotionEvent.ACTION_UP)
		{
			tts.speak("Bitte noch einmal!", TextToSpeech.QUEUE_ADD,null);		
		}
		return true;
	}

	@Override
	public void onInit(int status)
	{
		tts.setLanguage(Locale.GERMAN);
		tts.speak("Guten Tag! Bitte berühre mich!", TextToSpeech.QUEUE_FLUSH,null);		
	}
}
